import { DailyItem } from "./DailyItem";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { SPlayerCopy } from "../../../../../Message/Public/SPlayerCopy";
import { CopyConfig } from "../../../resource/CopyConfig";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { RemainTimeTool } from "../../award/RemainTimeTool";
import { CopyUtil } from "../../copy/CopyUtil";
import { Language } from "../../../../../extend/language/Language";
//class DailyCopyGradeItem
    
    export  class DailyCopyGradeItem extends DailyItem
    {
        constructor()
        {
            super();
            return;
        }

        public /* override */ initUI(): void
        {
            _bg = new Object /* flash.display.Sprite */();
            _bg.graphics.beginFill(0, 0);
            _bg.graphics.drawRect(0, 0, this.width, this.height);
            _bg.graphics.endFill();
            _bg.mouseEnabled = false;
            _bg.cacheAsBitmap = true;
            addChild(_bg);
            _selectLine = new Object /* flash.display.Sprite */();
            _selectLine.mouseEnabled = false;
            _selectLine.graphics.lineStyle(2, 65407, 1);
            _selectLine.graphics.drawRoundRect(1, 0, this.width - 12, this.height, 6, 6);
            _selectLine.graphics.endFill();
            _downLine = new Object /* flash.display.Sprite */();
            _downLine.mouseEnabled = false;
            _downLine.graphics.beginFill(880761, 1);
            _downLine.graphics.lineStyle(2, 16744192, 0);
            _downLine.graphics.drawRoundRect(1, 0, this.width - 12, this.height, 6, 6);
            _downLine.graphics.endFill();
            _downLine.cacheAsBitmap = true;
            _itemName = new Object /* flash.text.TextField */();
            _itemName.autoSize = flash.text.TextFieldAutoSize.CENTER;
            _itemName.width = 120;
            _itemName.x = 54;
            _itemName.y = 4;
            _itemName.textColor = 1310466;
            _itemName.text = "";
            _itemName.mouseEnabled = false;
            _itemName.filters = [FilterConst.nameGlowFilter];
            addChild(_itemName);
            _itemLevel = new Object /* flash.text.TextField */();
            _itemLevel.autoSize = flash.text.TextFieldAutoSize.CENTER;
            _itemLevel.width = 40;
            _itemLevel.x = 134;
            _itemLevel.y = _itemName.y;
            _itemLevel.textColor = 11464703;
            _itemLevel.text = "";
            _itemLevel.mouseEnabled = false;
            addChild(_itemLevel);
            this._heightestScore = new Object /* flash.text.TextField */();
            this._heightestScore.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._heightestScore.width = 75;
            this._heightestScore.x = 192;
            this._heightestScore.y = _itemName.y;
            this._heightestScore.textColor = 11464703;
            this._heightestScore.text = "";
            this._heightestScore.mouseEnabled = false;
            addChild(this._heightestScore);
            this._heightestGrade = new Object /* flash.text.TextField */();
            this._heightestGrade.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._heightestGrade.width = 80;
            this._heightestGrade.x = 259;
            this._heightestGrade.y = _itemName.y;
            this._heightestGrade.textColor = 11464703;
            this._heightestGrade.text = "";
            this._heightestGrade.mouseEnabled = false;
            addChild(this._heightestGrade);
            _itemTime = new Object /* flash.text.TextField */();
            _itemTime.autoSize = flash.text.TextFieldAutoSize.CENTER;
            _itemTime.width = 85;
            _itemTime.x = 342;
            _itemTime.y = _itemName.y;
            _itemTime.mouseEnabled = false;
            _itemTime.textColor = 11464703;
            _itemTime.text = "";
            addChild(_itemTime);
            this._numLabel = new Object /* flash.text.TextField */();
            this._numLabel.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._numLabel.width = 45;
            this._numLabel.x = 407;
            this._numLabel.y = _itemName.y;
            this._numLabel.mouseEnabled = false;
            this._numLabel.textColor = 11464703;
            this._numLabel.text = "";
            addChild(this._numLabel);
            _line = GlobalClass.getBitmap(ImagesConst.SplitLine);
            _line.y = 29;
            _line.x = 5;
            _line.width = 420;
            addChild(_line);
            this.addEventListener(flash.events.MouseEvent.MOUSE_OVER, onMouseOverHandler);
            this.addEventListener(flash.events.MouseEvent.MOUSE_OUT, onMouseOutHandler);
            return;
        }

        public get gradeInfo(): SPlayerCopy
        {
            return this._gradeInfo;
        }

        public updateGradeData(arg1: SPlayerCopy): void
        {
            var loc1=null;
            var loc2=null;
            this._gradeInfo = arg1;
            if (arg1) 
            {
                loc1 = CopyConfig.instance.getInfoByCode(arg1.copyCode);
                if (loc1) 
                {
                    _itemName.htmlText = HTMLUtil.addColor(loc1.name, "#13FF02");
                    _itemLevel.htmlText = HTMLUtil.addColor(String(loc1.enterMinLevel), GlobalStyle.color1);
                    _itemTime.htmlText = HTMLUtil.addColor(RemainTimeTool.getRemainTimeBySeconds(arg1.historyUseTime, false, true), GlobalStyle.color1);
                    this._numLabel.htmlText = HTMLUtil.addColor(arg1.todayEnterNum + "/" + CopyUtil.getCopyNumByDay(loc1), GlobalStyle.color1);
                    if (arg1.historyBestCredit > 0) 
                    {
                        _itemTime.htmlText = HTMLUtil.addColor(RemainTimeTool.getRemainTimeBySeconds(arg1.historyUseTime, false, true), GlobalStyle.color1);
                        this._heightestScore.htmlText = HTMLUtil.addColor(String(arg1.historyBestCredit), GlobalStyle.color1);
                        loc2 = CopyConfig.instance.getCopyGradeInfo(arg1.historyBestCredit);
                        if (loc2) 
                        {
                            this._heightestGrade.htmlText = loc2.levelStringWithColor;
                        }
                    }
                    else 
                    {
                        this._heightestScore.htmlText = HTMLUtil.addColor(Language.getString(90103), GlobalStyle.color1);
                        this._heightestGrade.htmlText = HTMLUtil.addColor(Language.getString(90103), GlobalStyle.color1);
                        _itemTime.htmlText = HTMLUtil.addColor(Language.getString(90103), GlobalStyle.color1);
                    }
                }
            }
            return;
        }

        public /* override */ get width(): number
        {
            return 440;
        }

        public /* override */ get height(): number
        {
            return 31;
        }

        /* internal */ /* var */_gradeInfo: SPlayerCopy;

        /* internal */ /* var */_heightestScore: Object /* flash.text.TextField */;

        /* internal */ /* var */_heightestGrade: Object /* flash.text.TextField */;

        /* internal */ /* var */_numLabel: Object /* flash.text.TextField */;
    }
